home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / Palettes / Chart / Source / PieChartPS.psw < prev    next >
Text File  |  1995-06-12  |  1KB  |  58 lines

  1. // -------------------------------------------------------------------------------------
  2. //  custom PS for PieChart palette
  3. // -------------------------------------------------------------------------------------
  4.  
  5. // draw a slice of pie
  6. defineps _pieDrawSlice(char *thelabel; float labelps;
  7.              float xCenter, yCenter, radius;
  8.             float startangle, endangle;
  9.             float grayOutline, grayLabel)
  10.  
  11.     gsave
  12.  
  13.     % translate to center of circle
  14.     xCenter yCenter translate
  15.  
  16.     % outline path to pie slice
  17.     newpath
  18.       0 0 moveto
  19.       0 0 radius startangle endangle arc
  20.     closepath
  21.     1.415 setmiterlimit
  22.  
  23.     % fill with default color and stroke the slice
  24.     gsave fill grestore
  25.     grayOutline 0 ge { grayOutline setgray stroke } { newpath } ifelse
  26.  
  27.     % draw tick and label
  28.     grayLabel 0 ge {
  29.     
  30.       % draw tick mark in center of arc
  31.       grayLabel setgray
  32.       gsave
  33.         startangle endangle add 2 div rotate
  34.         radius 0 translate
  35.         newpath
  36.           0 0 moveto
  37.           labelps .8 mul 0 lineto
  38.         stroke
  39.         labelps 0 translate
  40.        0 0 transform
  41.       grestore
  42.       itransform
  43.  
  44.       % draw label
  45.       /y exch def /x exch def
  46.       x y moveto
  47.       x 0 lt { (thelabel) stringwidth pop neg 1 sub 0 rmoveto } if
  48.       y 0.5 le { 0 labelps y -0.5 ge { 2 div } if neg rmoveto } if
  49.       0 labelps 0.10 mul rmoveto
  50.       (thelabel) show
  51.       
  52.     } if
  53.  
  54.     grestore
  55.  
  56. endps
  57.  
  58.